//
//  MarrySpeechCenterViewController.m
//  BaseProject
//
//  Created by 王洋 on 2020/9/14.
//  Copyright © 2020 王洋. All rights reserved.
//
#import "XLPageViewController.h"

#import "MarrySpeechSubViewController.h"

#import "MarrySpeechCenterViewController.h"

@interface MarrySpeechCenterViewController ()<XLPageViewControllerDelegate,XLPageViewControllerDataSrouce>

@property (nonatomic, strong) XLPageViewController *pageViewController;
//进入控制器时间
@property(nonatomic,strong)NSString *inTime;
@end

@implementation MarrySpeechCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initView];
    self.inTime = [NSString stringWithFormat:@"%0.0f",[Utilities getCurrentTimestamp]];
}
- (void)dealloc
{
    NSLog(@"MarrySpeechCenterViewController ---dealloc");
    [[StatisticManager shareManager]insertBrowseUserActiveQuantityWithToolType:@"7" WithInTime:self.inTime];
}
- (void)initView {

    self.title = @"誓言致辞库";
    self.view.backgroundColor = UIColorHex(0xffffff);
    
//    self.navigationController.navigationBarHidden = YES;
//    #if RT_INTERACTIVE_PUSH
//        self.rt_navigationController.rt_enableInteractivePush = YES;
//    #endif
    
//    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [btn setImage:[UIImage imageNamed:@"public_back_black"] forState:UIControlStateNormal];
//    [btn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    
    [self initPageViewController];
    
//    [self.view addSubview:btn];
//
//    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(kStatusBarHeight);
//        make.left.mas_equalTo(0);
//        make.height.mas_equalTo(NavBar_Height);
//        make.width.mas_equalTo(60);
//    }];
}

- (void)goBack {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initPageViewController {
    
    XLPageViewControllerConfig *config = [XLPageViewControllerConfig defaultConfig];
    config.shadowLineColor = UIColorHex(0xff4242);
    config.titleSelectedFont = [UIFont boldSystemFontOfSize:16];
    config.titleNormalFont = [UIFont systemFontOfSize:16];
    config.titleViewAlignment = XLPageTitleViewAlignmentCenter;
    config.showTitleInNavigationBar = false;
    config.separatorLineHidden = true;
    config.shadowLineAnimationType = XLPageShadowLineAnimationTypeZoom;
    config.shadowLineWidth = 20;
    config.titleSpace = 20;

    self.pageViewController = [[XLPageViewController alloc] initWithConfig:config];

    self.pageViewController.delegate = self;
    self.pageViewController.dataSource = self;
    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];
    
    [self.pageViewController.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
//        make.height.mas_equalTo(NavBar_Height);
    }];
}

#pragma mark -
#pragma mark TableViewDelegate&DataSource
- (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index {

    MarrySpeechSubViewController *vc = [[MarrySpeechSubViewController alloc] initWithType:(MarrySpeechSubType)index];
    return vc;
}

- (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index {
    return [self titles][index];
}

- (NSInteger)pageViewControllerNumberOfPage {
    return [self titles].count;
}

- (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index {
    NSLog(@"切换到了：%@",[self titles][index]);
}

#pragma mark -
#pragma mark 标题数据
- (NSArray *)titles {
    return @[@"新郎致辞",@"新娘致辞",@"父亲致辞",@"母亲致辞",@"伴郎致辞",@"伴娘致辞"];
}


@end
